package com.example.t470p.facechecktickets.Customer;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.t470p.facechecktickets.R;


public class ImportText extends RelativeLayout {
    private Context mContext;
    private View mView;
    private TextView textView;

    public ImportText(Context context) {
        this(context,null);
    }

    public ImportText(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public ImportText(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context,attrs);
    }

    private void initView(Context context, AttributeSet attrs) {
        mContext = context;
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mView = inflater.inflate(R.layout.inport_text,this,true);
        textView = (TextView) findViewById(R.id.im_text);

        TypedArray typedArray = mContext.obtainStyledAttributes(attrs,R.styleable.ImportText);
        if (typedArray != null){
            //设置文字
            String titleName = typedArray.getString(R.styleable.ImportText_title_name);
            setTitleName(titleName);
            //设置字体大小
            float size = typedArray.getDimension(R.styleable.ImportText_title_size,15);
            textView.setTextSize(size);
        }
        typedArray.recycle();
    }

    public void setTitleName(String titleName){
        if (!TextUtils.isEmpty(titleName)){
            textView.setText(titleName);
        }

    }
}
